{% load widget_tweaks %}

<form class="form-horizontal p-0 col-12" name="form1" method="get">
    <input type="hidden" name="project" value="{{ this_project.id }}">
    <div class="form-row col-12">
        <div class="form-group col-sm-6 col-md-1">
            <label for="id_limit" class="col-form-label">표시개수</label>
            <select name="limit" class="form-control" id="id_limit">
                <option value="" selected="">---------</option>
                <option value="5" {% if request.GET.limit == '5' %}selected{% endif %}>5 개</option>
                <option value="10" {% if request.GET.limit == '10' %}selected{% endif %}>10 개</option>
                <option value="15" {% if request.GET.limit == '15' %}selected{% endif %}>15 개</option>
                <option value="20" {% if request.GET.limit == '20' %}selected{% endif %}>20 개</option>
                <option value="25" {% if request.GET.limit == '25' %}selected{% endif %}>25 개</option>
                <option value="30" {% if request.GET.limit == '30' %}selected{% endif %}>30 개</option>
            </select>
        </div>

        <div class="form-group col-sm-6 col-md-1">
            <label for="id_group" class="col-form-label">차수구분</label>
            <select name="group" class="form-control" id="id_group">
                <option value="" selected="">---------</option>
                {% for group in groups %}
                    <option value="{{ group.id }}" {% if request.GET.group == group.id|stringformat:"s" %}selected{% endif %}>{{ group }}</option>
                {% endfor %}
            </select>
        </div>

        <div class="form-group col-sm-6 col-md-1">
            <label for="id_type" class="col-form-label">타입구분</label>
            <select name="type" class="form-control" id="id_type">
                <option value="" selected="">---------</option>
                {% for type in types %}
                    <option value="{{ type.id }}" {% if request.GET.type == type.id|stringformat:"s" %}selected{% endif %}>{{ type }}</option>
                {% endfor %}
            </select>
        </div>

        {% if this_project.is_unit_set %}
            <div class="form-group col-sm-6 col-md-1">
                <label for="id_dong" class="col-form-label">동별</label>
                <select name="dong" class="form-control" id="id_dong">
                    <option value="" selected="">---------</option>
                    {% for dong in dongs %}
                        <option value="{{ dong.bldg_no }}"
                                {% if request.GET.dong == dong.bldg_no %}selected{% endif %}>
                            {{ dong.bldg_no }} 동
                        </option>
                    {% endfor %}
                </select>
            </div>
        {% endif %}

        <div class="form-group col-sm-6 col-md-2">
            <label for="id_order" class="col-form-label">정렬순서</label>
            <select name="order" class="form-control" id="id_order">
                <option value="0" {% if request.GET.order == '0' %}selected{% endif %}>계약일자 오름차순</option>
                <option value="1" {% if request.GET.order == '1' %}selected{% endif %}>계약일자 내림차순</option>
                <option value="2" {% if request.GET.order == '2' %}selected{% endif %}>일련번호 오름차순</option>
                <option value="3" {% if request.GET.order == '3' %}selected{% endif %}>일련번호 내림차순</option>
                <option value="4" {% if request.GET.order == '4' %}selected{% endif %}>계약자명 오름차순</option>
                <option value="5" {% if request.GET.order == '5' %}selected{% endif %}>계약자명 내림차순</option>
            </select>
        </div>

        <div class="form-group col-sm-12 col-md-3">
            <div for="" class="col-form-label">현재 발행회차</div>
            <div class="text-center m-auto text-{% if bill_issue %}primary{% else %}danger{% endif %}" style="padding: 1px; background: lightyellow;">
                <h5>{{ bill_issue.now_payment_order|default:"발행회차 미설정 (기본 : 2회차)" }}</h5>
            </div>
        </div>

        <div class="form-group col-md-{% if this_project.is_unit_set %}3{% else %}4{% endif %}">
            <label for="id_q" class="d-none d-md-block col-form-label">&nbsp;</label>
            <div class="input-group">
                <input name="q" id="id_q" type="text" class="form-control"
                       placeholder="검색어 - 계약자명" aria-label="검색어 - 계약자명"
                       value="{{ request.GET.q }}"
                       onclick="this.value=''">
                <div class="input-group-append">
                    <input type="submit" class="btn btn-info btn-sm btn-block" value="검색">
                </div>
            </div>
        </div>
    </div>
</form>
